/**
 * 
 */
package datamodel.tree;

import datamodel.rucksack.Rucksack;

/**
 * An abstract class for a tree node. Holds the rucksack
 * 
 * @author Kevin Munk, Jakob Karolus
 * @version 1.0
 *
 */
public abstract class TreeNode {
	
	/**
	 * The Rucksack object contained by this TreeNode
	 */
	private Rucksack rucksack;
	
	
	/**
	 * constructor
	 * @param rucksack the rucksack for this node
	 */
	public TreeNode(Rucksack rucksack){
		this.rucksack = rucksack;
		}

	/**
	 * @return the weight of the rucksack in this node
	 */
	public int getWeight() {
		return this.rucksack.getWeight();
		}

	/**
	 * 
	 * @return the values of the rucksack in this node
	 */
	public int getValue() {
		return this.rucksack.getValue();
	}

	/**
	 * 
	 * @return the rucksack of this node
	 */
	public Rucksack getRucksack() {
		return this.rucksack;
	}
	
	/**
	 * Determines if this TreeNode is equal to a given TreeNode t
	 * @param t is the TreeNode to be compared
	 * @return true if this TreeNode is equal to the given TreeNode t
	 */
	private boolean equals(TreeNode t){
		if (this.rucksack == null){
			if (t.getRucksack() == null){
				return true;
			} else {
				return false;
			}
		}
		return this.rucksack.equals(t.getRucksack());
	}
	
	
	public boolean equals(Object o){
		if(o instanceof TreeNode){
			return this.equals((TreeNode) o);
		}
		return false;
	}
	

	
}
